<?php include_once('header.php');?>
	<div class="main-content">
		<div class="breadcrumbs" id="breadcrumbs">
			<script type="text/javascript">
				try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
			</script>
			<ul class="breadcrumb">
				<li>
					<i class="icon-home home-icon"></i>
					报价管理
				</li>
				<li>
					报价申请列表
				</li>
			</ul>
		</div>
		<div class="page-content">
			<div class="page-header">
				<h1 class="blue"><i class="icon-edit"></i> 编辑报价申请信息</h1>
			</div>
			<div class="row">
				<div class="col-xs-12">
					<form class="form-horizontal" enctype="multipart/form-data" role="form" method="post" action="/www/quote/edit"  onsubmit="return check()">
						<input type="hidden" class="form-control" id="id" name="id" value="<?php echo $data['id'];?>">
						<div class="form-group">
							<label for="title" class="col-sm-1 control-label">车主名:</label>
							<div class="col-sm-6">
								<input type="text" class="form-control" readonly="readonly" value="<?php echo $data['vehicle_owner'];?>">
							</div>
						</div>
						<div class="form-group">
							<label for="title" class="col-sm-1 control-label">联系方式:</label>
							<div class="col-sm-6">
								<input type="text" class="form-control" readonly="readonly" value="<?php echo $data['phone'];?>">
							</div>
						</div>
						<div class="form-group">
							<label for="title" class="col-sm-1 control-label">车型号:</label>
							<div class="col-sm-6">
								<input type="text" class="form-control" readonly="readonly" value="<?php echo $data['vehicle_model'];?>">
							</div>
						</div>
						<div class="form-group">
							<label for="title" class="col-sm-1 control-label">车牌号:</label>
							<div class="col-sm-6">
								<input type="text" class="form-control" readonly="readonly" value="<?php echo $data['car_num'];?>">
							</div>
						</div>
						<div class="form-group">
							<label for="title" class="col-sm-1 control-label">发动机:</label>
							<div class="col-sm-6">
								<input type="text" class="form-control" readonly="readonly" value="<?php echo $data['engine'];?>">
							</div>
						</div>
						<div class="form-group">
							<label for="title" class="col-sm-1 control-label">车架号:</label>
							<div class="col-sm-6">
								<input type="text" class="form-control" readonly="readonly" value="<?php echo $data['frame_num'];?>">
							</div>
						</div>
						<div class="form-group">
							<label for="title" class="col-sm-1 control-label">上季度保险公司:</label>
							<div class="col-sm-6">
								<input type="text" class="form-control" readonly="readonly" value="<?php echo $data['company_name'];?>">								
							</div>
						</div>
						<div class="form-group">
							<label for="title" class="col-sm-1 control-label">险种:</label>
							<div class="col-sm-6">
								<?php 
									foreach($insurance_list as $key => $value) {
										if(in_array($value['id'], $id_list)) {
											$str = '<option value="'.$value['id'].','. $value['sum_default'].'">'. $value['sum_default'].'</option>';
											$num = array_search($value['id'], $id_list);
											if($value['way'] != 1) {
												$sum_array = unserialize($value['sum_list']);
												foreach($sum_array as $k => $v) {
													if($v == $sum_list[$num]) {													
														$str .= '<option value="'.$value['id'].','.$v.'" selected = "selected">'.$v.'</option>';	
													}else {														
														$str .= '<option value="'.$value['id'].','.$v.'">'.$v.'</option>';
													}
												}
											}
											if($sum_list[$num]) {
												echo '<label style="width:100px;line-height:35px;"><input name="id_list[]" type="checkbox" checked="checked" value="'.$value['id'].'" />'.$value['name'].' </label>&nbsp;&nbsp;&nbsp;保额:&nbsp;<select name="sum[]" style="width:100px;">'.$str.'</select><br/>';												
											}else {
												echo '<label style="width:100px;line-height:35px;"><input name="id_list[]" type="checkbox" value="'.$value['id'].'" />'.$value['name'].' </label>&nbsp;&nbsp;&nbsp;保额:&nbsp;<select name="sum[]" style="width:100px;">'.$str.'</select><br/>';												
											}
										}									
									}
								?>
							</div>
						</div>
					 	<div class="form-group">
					   		<div class="col-sm-offset-1 col-sm-10">
								<button type="submit" id="submit" class="btn btn-primary">确定</button>
								<button type="submit" id="cancel" class="btn btn-primary">取消</button>
							</div>
					  	</div>
					</form>	
				</div>
			</div>					
		</div>													
	</div>
<?php include_once('content.php');?>
	<link href="/public_source/www/assets/css/ace.min.css" rel="stylesheet" />	
	<link href="/public_source/www/assets/css/jquery.tag-editor.css" rel="stylesheet"/>
    <script src="/public_source/www/assets/js/bootbox.min.js"></script>  
	<script src="/public_source/www/assets/js/jquery.tag-editor.min.js"></script>
	<script src="/public_source/www/js/areas.js"></script>
<?php include_once('footer.php');?>	
<script type="text/javascript">
	$(document).ready(function(){
		$("#cancel").click(function() {
			window.location.replace('/www/quote/quote_list');
			return false;
		});
	});
	function check() {	
		var id_list = document.getElementsByName("id_list[]");
	   	var id_bool = false;   
	   	for(var i = 0;i < id_list.length;++i) {	   
			if(id_list[i].checked == true) {
				id_bool = true;
			}		   
		}
	   	if(!id_bool) {
	    	alert("请至少选择一种险种");
	        return false;
	   	}
	   	return true;
	}			
</script>	
<style>
	.control-label {
		width:140px;
	}
</style>	